package com.mbyte.easy.admin.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.mbyte.easy.common.entity.BaseEntity;
import com.mbyte.easy.support.es.annotation.ESID;
import com.mbyte.easy.support.es.annotation.ESMetaData;
import com.mbyte.easy.support.es.constants.EsIndexConstants;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author lp
 * @since 2019-12-12
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("t_draft")
@ESMetaData(indexName= EsIndexConstants.INDEX_DRAFT)
public class Draft extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @ESID
    private long id;

    /**
     * 稿件标题
     */
    private String draftTitle;

    /**
     * 稿件内容
     */
    private String draftText;

    /**
     * 稿件字数
     */
    private Long draftNum;

    /**
     * 稿件类型
     */
    private Integer draftType;

    /**
     * 提交时间
     */
    private LocalDateTime submitTime;

    /**
     * 写手id（用户id）
     */
    private Long userId;

    /**
     * 写手名字
     */
    @TableField(exist = false)
    private String writerName;

    /**
     * 状态code
     */
    private Integer statusCode;

    /**
     * 是否删除（0是1否）
     */
    private Boolean isDelete;

    /**
     * 所属分组(1-写手组 2-稿件校对组 3-音频PPT制作组 4-音频PPT校对组 5-视频制作做 6-视频校对组',
     */
    private String groupId;
    @TableField(exist = false)
    private String groupName;

    /**
     * 最后操作人
     */
    private Long lastOperator;

    /**
     * 最后操作状态
     */
    private Integer isPass;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 修改时间
     */
    private LocalDateTime updateTime;
    /**
     * 截取的字符串
     */
    @TableField(exist = false)
    private String subText;

    /**
     * es同步类型
     */
    @TableField(exist = false)
    private int esSyncType;
    @TableField(exist = false)
    private float hitScore;

    @TableField(exist = false)
    private List<Long> idList;

    @Override
    public void setId(long id) {
        this.id = id;
    }

    public float getHitScore() {
        if(hitScore >= 100){
            hitScore = 90+ hitScore%10;
        }
        BigDecimal b = new BigDecimal(hitScore);
        return b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue(); //ROUND_HALF_UP表明四舍五入，;
    }


    @TableField(exist = false)
    public String AllotName;
    /**
    *被分配人
     */
    @TableField(exist = false)
    public String BeAllotName;

    /**
     * 文件名
     */
    private String fileName;

    /**
     * 重复率
     */
    private String repetitiveRate;

    /**
     * 视频id
     */
    private Long videoId;

    /**
     * 被分配人
     */
    @TableField(exist = false)
    private String allotNoName;
}
